/**
 * 
 */
package com.facebookdirectory.session;

import org.jboss.seam.annotations.Name;

import com.facebookdirectory.entity.Language;

/**
 * @author piglet
 *
 */
@Name("latestUpdateList")
public class LatestUpdateList extends AppInfoList {
	private static final long serialVersionUID = -6668650589429253168L;
	private static final String EJBQL = "select fBAppInfo from FBAppInfo fBAppInfo where fBappInfo.category = 'Games' order by fBAppInfo.lastUpdate desc";
	private static final String EJBQL_EN = "select fBAppInfo from FBAppInfo fBAppInfo where fBappInfo.category = 'Games' and fBappInfo.language=0 order by fBAppInfo.lastUpdate desc";
	private static final String EJBQL_CH = "select fBAppInfo from FBAppInfo fBAppInfo where fBappInfo.category = 'Games' and fBappInfo.language=1 order by fBAppInfo.lastUpdate desc";
	private Language language = Language.ENGLISH;
	
	public LatestUpdateList()
	{
		setEJBQL();			
	}
	
	private void setEJBQL() {
		switch(language)
		{
		case ENGLISH:
			setEjbql(EJBQL_EN);			
			break;
		case CHINESE:
			setEjbql(EJBQL_CH);
			break;
		default:
			setEjbql(EJBQL);			
		}		
	}

	public void changeToEnglish()
	{		
		language =  Language.ENGLISH;
		setEJBQL();
	}
	
	public void changeToChinese()
	{				
		language =  Language.CHINESE;		
		setEJBQL();
	}
}
